import type {PageParam, PageResult} from '@vben/request';
import type {Dayjs} from 'dayjs';

import {requestClient} from '#/api/request';
export namespace PerBusinessFamilyMarriageApi {
  /** 家庭成员外国人通婚业务表信息 */
  export interface BusinessFamilyMarriage {
    id: number; // 主键ID
    busiId?: string; // 业务主表ID
    familyMarriageId: number; // 正式表ID，对应 per_family_marriage.id，用于修改/删除时关联
    employeeId?: number; // 人员ID，对应 per_employee.id
    relation: string; // 与本人关系（称谓）
    systemPersonId: number; // 系统人员ID，对应 system_person.id
    familyName: string; // 配偶姓名
    cardType: string; // 证件类型
    familyIdcard: string; // 配偶身份证号
    country: string; // 国籍地区
    workUnit: string; // 工作学习单位
    position: string; // 职务
    registrationTime: string | Dayjs; // 登记时间
    residenceAfterMarriage: string; // 婚后居住地
    status: number; // 状态（1：有效，0：无效）
    changeType: string; // 变更类型（add 新增，update 修改，delete 删除）
    changeContent: string; // 变更内容(JSON格式，仅修改时记录差异)
    auditStatus: number; // 审核状态（0 草稿 1 审核中 2 审核完成）
    finalAuditStatus: number; // 最终审核状态（0 待审核 1 审核通过 2 审核不通过）
    auditTime: string | Dayjs; // 审核完成时间
    auditor: string; // 审核人
    auditComment: string; // 审核意见
    metadata: string; // 其他参数
  }
}

/** 查询家庭成员外国人通婚业务表分页 */
export function getBusinessFamilyMarriagePage(data: PageParam,desensitize: boolean,encrypt: boolean) {
  return requestClient.post<PageResult<PerBusinessFamilyMarriageApi.BusinessFamilyMarriage>>('/per/business-family-marriage/page', data,{ desensitize,encrypt });
}

/** 查询家庭成员外国人通婚业务表详情 */
export function getBusinessFamilyMarriage(params: { id: number }) {
  return requestClient.get<PerBusinessFamilyMarriageApi.BusinessFamilyMarriage>(
    `/per/business-family-marriage/get?id=${params.id}`,
  );
}

/** 新增家庭成员外国人通婚业务表 */
export function createBusinessFamilyMarriage(data: PerBusinessFamilyMarriageApi.BusinessFamilyMarriage) {
  return requestClient.post('/per/business-family-marriage/create', data);
}

/** 修改家庭成员外国人通婚业务表 */
export function updateBusinessFamilyMarriage(data: PerBusinessFamilyMarriageApi.BusinessFamilyMarriage) {
  return requestClient.put('/per/business-family-marriage/update', data);
}

/** 删除家庭成员外国人通婚业务表 */
export function deleteBusinessFamilyMarriage(params: { id: number }) {
  return requestClient.delete(
    `/per/business-family-marriage/delete?id=${params.id}`,
  );
}

/** 批量删除家庭成员外国人通婚业务表 */
export function deleteBusinessFamilyMarriageList(ids: number[]) {
  return requestClient.delete(`/per/business-family-marriage/delete-list?ids=${ids.join(',')}`)
}

/** 导出家庭成员外国人通婚业务表 */
export function exportBusinessFamilyMarriage(params: any) {
  return requestClient.download(
    '/per/business-family-marriage/export-excel',
    { params },
  );
}

/** 根据业务主表id去查询业务数据 */
export function getFamilyMarriageBusiId(data: any) {
  return requestClient.post<PerBusinessFamilyMarriageApi.BusinessFamilyMarriage>(
    '/per/business-family-marriage/getFamilyMarriageBusiId',
    data,
  );
}

/** 获取当前登录人家庭成员外国人通婚情况 */
export function getCurrentFamilyMarriage(
  data,
  desensitize: boolean,
  encrypt?: boolean,
) {
  return requestClient.post<
    List<PerBusinessFamilyMarriageApi.BusinessFamilyMarriage>
  >('/per/business-family-marriage/getCurrentFamilyMarriage', data, {
    desensitize,
    encrypt,
  });
}
